<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浮动元素之父元素高度自适应1</title>
    <style>
        .right,.left{
            height: 100px;
            width: 100px;
            float: left;
        
        }
        .left{
            background: red;
        }
        .right{
            background: yellow;
        }
        .content{
            height: 200px;
            width: 200px;
            background-color: green;
        }
        /* 
        .box{
            height: 100px;设置父元素高度
        }   
        1.如果浮动过多，换行就会出现问题    
        */
        .box{
            overflow: hidden;
            /* 3.会隐藏溢出文本 */
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="left"></div>
        <div class="right"></div>
        <!-- <div style="clear: both;"></div> -->
        <!-- 2.增加空标签，不利于代码可读性 -->
    </div>
    <div class="content"></div>
</body>
</html>